<!DOCTYPE html>
<html>
<head>
    

    

    
<!-- Baidu Tongji -->
<script>var _hmt = _hmt || []</script>
<script async src="//hm.baidu.com/hm.js?a7c05ce530152d9866930ef4850ee566"></script>
<!-- End Baidu Tongji -->




    <meta charset="utf-8">
    
    
    
    <title>全文检索技术Solr6.6.0 | 神奇的鸭鸭の码农库 | 新知识要不断的总结记录成笔记，要多写，多画，能够清晰透彻的将知识讲给别人听，才是达到理解的层次。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#765959">
    
    
    <meta name="keywords" content="全文检索">
    <meta name="description" content="Solr介绍Solr是Apache下的一个顶级开源项目，采用Java开发，它是基于Lucene的全文搜索服务器。Solr可以独立运行在Jetty、Tomcat等这些Servlet容器中。Solr提供了比Lucene更为丰富的查询语言，同时实现了可配置、可扩展，并对索引、搜索性能进行了优化。使用Solr进行创建索引和搜索索引的实现方法很简单，如下： 创建索引：客户端(可以是浏览器可以是Java程序)">
<meta name="keywords" content="全文检索">
<meta property="og:type" content="article">
<meta property="og:title" content="全文检索技术Solr6.6.0">
<meta property="og:url" content="http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/index.html">
<meta property="og:site_name" content="神奇的鸭鸭の码农库">
<meta property="og:description" content="Solr介绍Solr是Apache下的一个顶级开源项目，采用Java开发，它是基于Lucene的全文搜索服务器。Solr可以独立运行在Jetty、Tomcat等这些Servlet容器中。Solr提供了比Lucene更为丰富的查询语言，同时实现了可配置、可扩展，并对索引、搜索性能进行了优化。使用Solr进行创建索引和搜索索引的实现方法很简单，如下： 创建索引：客户端(可以是浏览器可以是Java程序)">
<meta property="og:updated_time" content="2017-12-05T09:59:55.098Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="全文检索技术Solr6.6.0">
<meta name="twitter:description" content="Solr介绍Solr是Apache下的一个顶级开源项目，采用Java开发，它是基于Lucene的全文搜索服务器。Solr可以独立运行在Jetty、Tomcat等这些Servlet容器中。Solr提供了比Lucene更为丰富的查询语言，同时实现了可配置、可扩展，并对索引、搜索性能进行了优化。使用Solr进行创建索引和搜索索引的实现方法很简单，如下： 创建索引：客户端(可以是浏览器可以是Java程序)">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="/css/style.css?v=1.4.3">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">神奇的鸭鸭</h5>
          <a href="mailto:702038338@qq.com" title="702038338@qq.com" class="mail">702038338@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://git.oschina.net/magic_duck" target="_blank" >
                <i class="icon icon-lg icon-gg-circle"></i>
                码云
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://www.zhihu.com/people/shen-qi-de-ya-ya" target="_blank" >
                <i class="icon icon-lg icon-twitter"></i>
                知乎
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/404.html"  >
                <i class="icon icon-lg icon-link"></i>
                404页面测试
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">全文检索技术Solr6.6.0</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">全文检索技术Solr6.6.0</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-09-04T08:05:00.000Z" itemprop="datePublished" class="page-time">
  2017-09-04
</time>


            
        </h5>
    </div>

    

</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Solr介绍"><span class="post-toc-number">1.</span> <span class="post-toc-text">Solr介绍</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Solr和Lucene的区别"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">Solr和Lucene的区别</span></a></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Solr安装配置"><span class="post-toc-number">2.</span> <span class="post-toc-text">Solr安装配置</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#配置多solrcore"><span class="post-toc-number">2.1.</span> <span class="post-toc-text">配置多solrcore</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#界面介绍"><span class="post-toc-number">2.2.</span> <span class="post-toc-text">界面介绍</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Core-selector详解"><span class="post-toc-number">2.3.</span> <span class="post-toc-text">Core selector详解</span></a></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Solr的基本使用"><span class="post-toc-number">3.</span> <span class="post-toc-text">Solr的基本使用</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#managed-schema文件"><span class="post-toc-number">3.1.</span> <span class="post-toc-text">managed-schema文件</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#field"><span class="post-toc-number">3.2.</span> <span class="post-toc-text">field</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#fieldType（域类型）"><span class="post-toc-number">3.3.</span> <span class="post-toc-text">fieldType（域类型）</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#uniqueKey"><span class="post-toc-number">3.4.</span> <span class="post-toc-text">uniqueKey</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#copyField（复制域）"><span class="post-toc-number">3.5.</span> <span class="post-toc-text">copyField（复制域）</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#dynamicField（动态域）"><span class="post-toc-number">3.6.</span> <span class="post-toc-text">dynamicField（动态域）</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#配置中文分词器"><span class="post-toc-number">3.7.</span> <span class="post-toc-text">配置中文分词器</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#配置业务field"><span class="post-toc-number">3.8.</span> <span class="post-toc-text">配置业务field</span></a></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Solrj的使用"><span class="post-toc-number">4.</span> <span class="post-toc-text">Solrj的使用</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#使用solrj调用solr服务实现对索引库的增删改查操作"><span class="post-toc-number">4.1.</span> <span class="post-toc-text">使用solrj调用solr服务实现对索引库的增删改查操作</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#添加-修改索引"><span class="post-toc-number">4.2.</span> <span class="post-toc-text">添加\修改索引</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#删除索引"><span class="post-toc-number">4.3.</span> <span class="post-toc-text">删除索引</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#查询索引"><span class="post-toc-number">4.4.</span> <span class="post-toc-text">查询索引</span></a></li></ol></li></ol>
        </nav>
    </aside>
    
<article id="post-Solr6.6.0_primary_01"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">全文检索技术Solr6.6.0</h1>
        <div class="post-meta">
            <time class="post-time" title="2017年09月04日 16:05" datetime="2017-09-04T08:05:00.000Z"  itemprop="datePublished">2017-09-04</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="Solr介绍"><a href="#Solr介绍" class="headerlink" title="Solr介绍"></a>Solr介绍</h2><p>Solr是Apache下的一个顶级开源项目，采用Java开发，它是基于Lucene的<strong>全文搜索服务器</strong>。Solr可以独立运行在Jetty、Tomcat等这些Servlet容器中。Solr提供了比Lucene更为<strong>丰富的查询语言，同时实现了可配置、可扩展，并对索引、搜索性能进行了优化。</strong>使用Solr进行创建索引和搜索索引的实现方法很简单，如下：</p>
<p><strong>创建索引：</strong>客户端(可以是浏览器可以是Java程序)用POST方法向Solr服务器发送一个描述Field及其内容的XML文档，Solr服务器根据xml文档添加、删除、更新索引。</p>
<p><strong>搜索索引：</strong>客户端(可以是浏览器可以是Java程序)用GET方法向Solr服务器发送请求，然后对Solr服务器返回Xml、json等格式的查询结果进行解析，组织页面布局。Solr不提供构建页面UI的功能，但是<strong>Solr提供了一个管理界面，通过管理界面可以查询Solr的配置和运行情况。</strong></p>
<h3 id="Solr和Lucene的区别"><a href="#Solr和Lucene的区别" class="headerlink" title="Solr和Lucene的区别"></a>Solr和Lucene的区别</h3><p><strong>Lucene是一个开发源代码的全文检索引擎工具包，</strong>它不是一个完整的全文检索应用。Lucene仅提供了完整的查询引擎和索引引擎，目的是为软件开发人员提供一个简单易用的工具包，以方便的在目标系统中实现全文检索的功能，或者以Lucene为基础构建全文检索应用。</p>
<p><strong>Solr的目标是打造一款企业级的搜索引擎系统，它是基于Lucene的一个搜索引擎服务，</strong>可以独立运行，通过Solr可以非常快速的构建企业的搜索引擎，通过Solr也可以高效的完成站内搜索功能。</p>
<h2 id="Solr安装配置"><a href="#Solr安装配置" class="headerlink" title="Solr安装配置"></a>Solr安装配置</h2><p>Solr 需要运行在一个Servlet容器中，Solr默认提供Jetty(java写的Servlet容器)，本教程使用Tocmat作为Servlet容器，相关环境如下：</p>
<ul>
<li>Solr：6.6.0 <a href="http://archive.apache.org/dist/lucene/solr/" target="_blank" rel="external">http://archive.apache.org/dist/lucene/solr/</a></li>
<li>Jdk环境：1.8</li>
<li>Web服务器(servlet容器)：Tomcat8.5</li>
</ul>
<p>下载后解压可查看其目录结构：</p>
<ul>
<li>bin：solr的运行脚本</li>
<li>contrib：solr的一些扩展jar包，用于增强solr的功能。</li>
<li>dist：该目录包含build过程中产生的war和jar文件，以及相关的依赖文件。</li>
<li>docs：solr的API文档</li>
<li>example：solr工程的例子目录</li>
<li>licenses：solr相关的一些许可信息</li>
<li><p>server：该目录中包括一个solr-webapp，可作为solr的运行实例工程。</p>
</li>
<li><p>1 将下载的solr-6.6.0\server\solr-webapp下的webapp复制到tomcat下的webapps中，并将其改名为solr。</p>
</li>
<li>2 拷贝\solr-6.6.0\server\lib\ext下的jar包，solr-6.6.0\dist下的solr-dataimporthandler.jar，solr-dataimporthandler-extras.jar到solr项目的WEB-INF\lib中。</li>
<li>3 拷贝solr-6.6.0\server\lib下所有metrics开头的jar包到solr项目的WEB-INF\lib中。</li>
<li>4 在tomcat\webapps\solr\WEB-INF下新建classes目录，并拷贝solr6.6.0\server\resources下的log4j.properties文件复制其中。</li>
<li>5 拷贝solr_dev\solr-6.6.0\server下的solr文件夹到tomcat下的webapps下，重命名为solrhome</li>
<li>6 在solr_home下新建一个new_core文件夹，并将solr_home\configsets\sample_techproducts_configs下的conf文件夹拷贝到new_core文件夹中(配置错误抛出Error CREATEing SolrCore ‘new_core’: Unable to create core [new_core] Caused by: Can’t find resource ‘solrconfig.xml’ in classpath or ‘D:\tomcat\tomcat8.5-eclipse-8081\webapps\solrhome\new_core’)。<strong>一个SolrHome可以包括多个SolrCore（Solr实例），每个SolrCore提供单独的搜索和索引服务。</strong></li>
<li><p>7 修改solr\WEB-INF\web.xml用于指定solrhome对的目录：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">env-entry</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">env-entry-name</span>&gt;</span>solr/home<span class="tag">&lt;/<span class="name">env-entry-name</span>&gt;</span></div><div class="line">    <span class="comment">&lt;!-- 此处配置SolrHome的路径，改目录是你新建的 --&gt;</span></div><div class="line">    <span class="comment">&lt;!-- SolrHome是Solr运行的主目录，该目录中包括了多个SolrCore目录。SolrCore目录中包含了运行Solr实例所有的配置文件和数据文件，Solr实例就是SolrCore。 --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">env-entry-value</span>&gt;</span>D:\tomcat\tomcat8.5-solr-8081\solr\solr_home<span class="tag">&lt;/<span class="name">env-entry-value</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">env-entry-type</span>&gt;</span>java.lang.String<span class="tag">&lt;/<span class="name">env-entry-type</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">env-entry</span>&gt;</span></div><div class="line"></div><div class="line">  <span class="comment">&lt;!-- 这段配置现在了对solr资源的访问，注释掉就可以访问了</span></div><div class="line"><span class="comment">  &lt;security-constraint&gt;</span></div><div class="line"><span class="comment">    &lt;web-resource-collection&gt;</span></div><div class="line"><span class="comment">      &lt;web-resource-name&gt;Disable TRACE&lt;/web-resource-name&gt;</span></div><div class="line"><span class="comment">      &lt;url-pattern&gt;/&lt;/url-pattern&gt;</span></div><div class="line"><span class="comment">      &lt;http-method&gt;TRACE&lt;/http-method&gt;</span></div><div class="line"><span class="comment">    &lt;/web-resource-collection&gt;</span></div><div class="line"><span class="comment">    &lt;auth-constraint/&gt;</span></div><div class="line"><span class="comment">  &lt;/security-constraint&gt;</span></div><div class="line"><span class="comment">  &lt;security-constraint&gt;</span></div><div class="line"><span class="comment">    &lt;web-resource-collection&gt;</span></div><div class="line"><span class="comment">      &lt;web-resource-name&gt;Enable everything but TRACE&lt;/web-resource-name&gt;</span></div><div class="line"><span class="comment">      &lt;url-pattern&gt;/&lt;/url-pattern&gt;</span></div><div class="line"><span class="comment">      &lt;http-method-omission&gt;TRACE&lt;/http-method-omission&gt;</span></div><div class="line"><span class="comment">    &lt;/web-resource-collection&gt;</span></div><div class="line"><span class="comment">  &lt;/security-constraint&gt; --&gt;</span></div></pre></td></tr></table></figure>
</li>
<li><p>8 在solr\solr_home\new_core\conf下有一个solrconfig.xml文件，在该文件中，主要配置三个标签：lib标签、datadir标签、requestHandler(请求处理器，定义了索引和搜索的访问方式)标签  (如果对该文件不进行配置也可以，即使用默认的配置项)。</p>
</li>
<li><p>9 先将下载的solr-6.6.0下的contrib和dist拷贝到solr\solr_home下。然后配置正确的llib路径：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- 配置路径错误会有警告：SolrConfig Couldn't add files form ... --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/contrib/extraction/lib"</span> <span class="attr">regex</span>=<span class="string">".*\.jar"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/dist/"</span> <span class="attr">regex</span>=<span class="string">"solr-cell-\d.*\.jar"</span> /&gt;</span></div><div class="line"></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/contrib/clustering/lib/"</span> <span class="attr">regex</span>=<span class="string">".*\.jar"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/dist/"</span> <span class="attr">regex</span>=<span class="string">"solr-clustering-\d.*\.jar"</span> /&gt;</span></div><div class="line"></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/contrib/langid/lib/"</span> <span class="attr">regex</span>=<span class="string">".*\.jar"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/dist/"</span> <span class="attr">regex</span>=<span class="string">"solr-langid-\d.*\.jar"</span> /&gt;</span></div><div class="line"></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/contrib/ltr/lib/"</span> <span class="attr">regex</span>=<span class="string">".*\.jar"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/dist/"</span> <span class="attr">regex</span>=<span class="string">"solr-ltr-\d.*\.jar"</span> /&gt;</span></div><div class="line"></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/contrib/velocity/lib"</span> <span class="attr">regex</span>=<span class="string">".*\.jar"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:../..&#125;/dist/"</span> <span class="attr">regex</span>=<span class="string">"solr-velocity-\d.*\.jar"</span> /&gt;</span>s</div></pre></td></tr></table></figure>
</li>
<li><p>10 配置datadir标签：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- 每个SolrCore都有自己的索引文件目录 ，默认在SolrCore目录下的data中，允许自定义路径</span></div><div class="line"><span class="comment">  data数据目录下包括了index索引目录 和tlog日志文件目录。</span></div><div class="line"><span class="comment"> --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">dataDir</span>&gt;</span>$&#123;solr.data.dir:&#125;<span class="tag">&lt;/<span class="name">dataDir</span>&gt;</span></div></pre></td></tr></table></figure>
</li>
<li><p>11 启动tomcat：<a href="http://localhost:8081/solr/index.html" target="_blank" rel="external">http://localhost:8081/solr/index.html</a></p>
</li>
</ul>
<h3 id="配置多solrcore"><a href="#配置多solrcore" class="headerlink" title="配置多solrcore"></a>配置多solrcore</h3><p>复制solrhome下的new_code目录到本目录下，修改名称为new_code2，然后修改core.properties文件即可，配置多SolrCore的好处： </p>
<ul>
<li>1 一个solr工程对外通过SorlCore 提供服务，每个SolrCore相当于一个数据库，这个功能就相当于一个mysql可以运行多个数据库。</li>
<li>2 将索引数据分SolrCore存储，方便对索引数据管理维护。</li>
<li>3 SolrCloud集群需要使用多core。</li>
</ul>
<h3 id="界面介绍"><a href="#界面介绍" class="headerlink" title="界面介绍"></a>界面介绍</h3><table>
<thead>
<tr>
<th style="text-align:left">列表</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Dashboard</td>
<td style="text-align:left">仪表盘，显示了该Solr实例开始启动运行的时间、版本、系统资源、jvm等信息。</td>
</tr>
<tr>
<td style="text-align:left">Logging</td>
<td style="text-align:left">Solr运行日志信息</td>
</tr>
<tr>
<td style="text-align:left">Core Admin</td>
<td style="text-align:left">Solr Core的管理界面。在这里可以添加SolrCore实例</td>
</tr>
<tr>
<td style="text-align:left">java properties</td>
<td style="text-align:left">Solr在JVM 运行环境中的属性信息，包括类路径、文件编码、jvm内存设置等信息</td>
</tr>
<tr>
<td style="text-align:left">Tread Dump</td>
<td style="text-align:left">显示Solr Server中当前活跃线程信息，同时也可以跟踪线程运行栈信息</td>
</tr>
<tr>
<td style="text-align:left">Core selector</td>
<td style="text-align:left">选择一个SolrCore进行详细操作，细节如下：</td>
</tr>
</tbody>
</table>
<h3 id="Core-selector详解"><a href="#Core-selector详解" class="headerlink" title="Core selector详解"></a>Core selector详解</h3><table>
<thead>
<tr>
<th style="text-align:left">列表</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><strong>Analysis</strong></td>
<td style="text-align:left">通过此界面可以测试索引分析器和搜索分析器的执行情况。注：solr中，分析器是绑定在域的类型中的。</td>
</tr>
<tr>
<td style="text-align:left">dataimport</td>
<td style="text-align:left">可以定义数据导入处理器，从关系数据库将数据导入到Solr索引库中。默认没有配置，需要手工配置。</td>
</tr>
<tr>
<td style="text-align:left"><strong>Document</strong></td>
<td style="text-align:left">通过/update表示更新索引，solr默认根据id（唯一约束）域来更新Document的内容，如果根据id值搜索不到id域则会执行添加操作，如果找到则更新。overwrite=”true”：solr在做索引的时候，如果文档已经存在，就用xml中的文档进行替换。commitWithin=”1000”：solr 在做索引的时候，每个1000（1秒）毫秒，做一次文档提交。</td>
</tr>
<tr>
<td style="text-align:left"><strong>Query</strong></td>
<td style="text-align:left">通过/select执行搜索索引，必须指定”q”查询条件方可搜索。</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="Solr的基本使用"><a href="#Solr的基本使用" class="headerlink" title="Solr的基本使用"></a>Solr的基本使用</h2><h3 id="managed-schema文件"><a href="#managed-schema文件" class="headerlink" title="managed-schema文件"></a>managed-schema文件</h3><p>该文件在new_code下的conf目录下，是solr数据表配置文件，在该文件中配置了域与域的类型还有一些其他配置，在solr中域必须<strong>先定义后使用</strong>。</p>
<h3 id="field"><a href="#field" class="headerlink" title="field"></a>field</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!--</span></div><div class="line"><span class="comment">  name：域的名称</span></div><div class="line"><span class="comment">  type：域的类型</span></div><div class="line"><span class="comment">  indexed：是否索引</span></div><div class="line"><span class="comment">  stored：是否存储</span></div><div class="line"><span class="comment">  required：是否必须</span></div><div class="line"><span class="comment">  multiValued：是否多值，存储多个值时设置为true，solr允许field存储多个值，比如存储一个用户的好友id（多个），商品的图片（多个，大图和小图）</span></div><div class="line"><span class="comment"> --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"id"</span> <span class="attr">type</span>=<span class="string">"string"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"true"</span> <span class="attr">required</span>=<span class="string">"true"</span> <span class="attr">multiValued</span>=<span class="string">"false"</span> /&gt;</span></div></pre></td></tr></table></figure>
<h3 id="fieldType（域类型）"><a href="#fieldType（域类型）" class="headerlink" title="fieldType（域类型）"></a>fieldType（域类型）</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- </span></div><div class="line"><span class="comment">  name：域类型的名称</span></div><div class="line"><span class="comment">  class：指定域类型的solr类型</span></div><div class="line"><span class="comment"> --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">fieldType</span> <span class="attr">name</span>=<span class="string">"text_general"</span> <span class="attr">class</span>=<span class="string">"solr.TextField"</span> <span class="attr">positionIncrementGap</span>=<span class="string">"100"</span>&gt;</span></div><div class="line">  <span class="comment">&lt;!-- </span></div><div class="line"><span class="comment">    analyzer：指定分词器。在FieldType定义的时候最重要的就是定义这个类型的数据在建立索引和进行查询的时候要使用的分析器analyzer，包括分词和过滤</span></div><div class="line"><span class="comment">    type：index和query。Index 是创建索引，query是查询索引</span></div><div class="line"><span class="comment">    tokenizer：指定分词器</span></div><div class="line"><span class="comment">    filter：指定过滤器</span></div><div class="line"><span class="comment">   --&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">analyzer</span> <span class="attr">type</span>=<span class="string">"index"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">tokenizer</span> <span class="attr">class</span>=<span class="string">"solr.StandardTokenizerFactory"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">filter</span> <span class="attr">class</span>=<span class="string">"solr.StopFilterFactory"</span> <span class="attr">ignoreCase</span>=<span class="string">"true"</span> <span class="attr">words</span>=<span class="string">"stopwords.txt"</span> /&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">filter</span> <span class="attr">class</span>=<span class="string">"solr.LowerCaseFilterFactory"</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">analyzer</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">analyzer</span> <span class="attr">type</span>=<span class="string">"query"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">tokenizer</span> <span class="attr">class</span>=<span class="string">"solr.StandardTokenizerFactory"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">filter</span> <span class="attr">class</span>=<span class="string">"solr.StopFilterFactory"</span> <span class="attr">ignoreCase</span>=<span class="string">"true"</span> <span class="attr">words</span>=<span class="string">"stopwords.txt"</span> /&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">filter</span> <span class="attr">class</span>=<span class="string">"solr.SynonymGraphFilterFactory"</span> <span class="attr">synonyms</span>=<span class="string">"synonyms.txt"</span> <span class="attr">ignoreCase</span>=<span class="string">"true"</span> <span class="attr">expand</span>=<span class="string">"true"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">filter</span> <span class="attr">class</span>=<span class="string">"solr.LowerCaseFilterFactory"</span>/&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">analyzer</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">fieldType</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="uniqueKey"><a href="#uniqueKey" class="headerlink" title="uniqueKey"></a>uniqueKey</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- 相当于主键，每个文档中必须有一个id域 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">uniqueKey</span>&gt;</span>id<span class="tag">&lt;/<span class="name">uniqueKey</span>&gt;</span></div></pre></td></tr></table></figure>
<h3 id="copyField（复制域）"><a href="#copyField（复制域）" class="headerlink" title="copyField（复制域）"></a>copyField（复制域）</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- 可以将多个Field复制到一个Field中，以便进行统一的检索。当创建索引时，solr服务器会自动的将源域的内容复制到目标域中</span></div><div class="line"><span class="comment">  source：源域</span></div><div class="line"><span class="comment">  dest：目标域，搜索时，指定目标域为搜索域，可以提高查询效率</span></div><div class="line"><span class="comment"> --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">copyField</span> <span class="attr">source</span>=<span class="string">"cat"</span> <span class="attr">dest</span>=<span class="string">"text"</span>/&gt;</span></div><div class="line"></div><div class="line"><span class="comment">&lt;!-- 定义目标域（必须要使用：multiValued="true"） --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"text"</span> <span class="attr">type</span>=<span class="string">"text_general"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"false"</span> <span class="attr">multiValued</span>=<span class="string">"true"</span>/&gt;</span></div></pre></td></tr></table></figure>
<h3 id="dynamicField（动态域）"><a href="#dynamicField（动态域）" class="headerlink" title="dynamicField（动态域）"></a>dynamicField（动态域）</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!--</span></div><div class="line"><span class="comment">  name：动态域的名称，是一个表达式，*匹配任意字符，只要域的名称和表达式的规则能够匹配就可以使用。</span></div><div class="line"><span class="comment">  例如：搜索时查询条件【product_i：钻石】就可以匹配这个动态域，可以直接使用，不用单独再定义一个product_i域。</span></div><div class="line"><span class="comment"> --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">dynamicField</span> <span class="attr">name</span>=<span class="string">"*_i"</span>  <span class="attr">type</span>=<span class="string">"int"</span>  <span class="attr">indexed</span>=<span class="string">"true"</span>  <span class="attr">stored</span>=<span class="string">"true"</span>/&gt;</span></div></pre></td></tr></table></figure>
<h3 id="配置中文分词器"><a href="#配置中文分词器" class="headerlink" title="配置中文分词器"></a>配置中文分词器</h3><p>使用IKAnalyzer中文分析器</p>
<ul>
<li>1 把IKAnalyzer.jar添加到solr/WEB-INF/lib目录下</li>
<li>2 复制IKAnalyzer的配置文件和自定义词典和停用词词典到solr的classpath下</li>
<li>3 在schema.xml中添加一个自定义的fieldType，使用中文分析器</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- IKAnalyzer--&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">fieldType</span> <span class="attr">name</span>=<span class="string">"text_ik"</span> <span class="attr">class</span>=<span class="string">"solr.TextField"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">analyzer</span> <span class="attr">class</span>=<span class="string">"org.wltea.analyzer.lucene.IKAnalyzer"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">fieldType</span>&gt;</span></div></pre></td></tr></table></figure>
<ul>
<li><p>4 定义field，指定field的type属性为text_ik</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"content_ik"</span> <span class="attr">type</span>=<span class="string">"text_ik"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"false"</span> <span class="attr">multiValued</span>=<span class="string">"true"</span>/&gt;</span></div></pre></td></tr></table></figure>
</li>
<li><p>5 接下來重启tomcat，进入Core selector的Analysis进行测试</p>
</li>
</ul>
<h3 id="配置业务field"><a href="#配置业务field" class="headerlink" title="配置业务field"></a>配置业务field</h3><p>需求：要使用solr实现电商网站中商品搜索。电商中商品信息在mysql数据库中存储了，将mysql数据库中数据在solr中创建索引。需要在solr的schema.xml文件定义商品Field。</p>
<p>先确定定义的商品document的field有哪些，可以根据mysql数据库的字段来确定，当前准备表product，当前商品document的field包括：pid、name、catalog、catalog_name、price、description、picture，然后定义Fieldtype，由于中文分词器已经配置完FieldType，所以目前FieldType已经满足需要，无需配置。所以直接定义field：<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- pid、name、catalog、catalog_name、price、description、picture --&gt;</span></div><div class="line"><span class="comment">&lt;!-- 由于pid在products表中是唯一键，而且在solr的shema.xml中已有一个id的唯一键配置，所以不需要再重新定义pid域 --&gt;</span></div><div class="line"><span class="comment">&lt;!-- 商品名称 name --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"product_name"</span> <span class="attr">type</span>=<span class="string">"text_ik"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"true"</span> /&gt;</span></div><div class="line"><span class="comment">&lt;!-- 商品分类ID catalog --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"product_catalog"</span> <span class="attr">type</span>=<span class="string">"string"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"true"</span> /&gt;</span></div><div class="line"><span class="comment">&lt;!-- 商品分类 catalog_name --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"product_catalog_name"</span> <span class="attr">type</span>=<span class="string">"string"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"false"</span> /&gt;</span></div><div class="line"><span class="comment">&lt;!-- 商品价格 price --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"product_price"</span> <span class="attr">type</span>=<span class="string">"float"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"true"</span> /&gt;</span></div><div class="line"><span class="comment">&lt;!-- 商品描述 description --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"product_description"</span> <span class="attr">type</span>=<span class="string">"text_ik"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"false"</span>/&gt;</span></div><div class="line"><span class="comment">&lt;!-- 商品图片地址 picture --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"product_picture"</span> <span class="attr">type</span>=<span class="string">"string"</span> <span class="attr">indexed</span>=<span class="string">"false"</span> <span class="attr">stored</span>=<span class="string">"true"</span>/&gt;</span></div><div class="line"></div><div class="line"><span class="comment">&lt;!-- 目标域 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">field</span> <span class="attr">name</span>=<span class="string">"product_keywords"</span> <span class="attr">type</span>=<span class="string">"text_ik"</span> <span class="attr">indexed</span>=<span class="string">"true"</span> <span class="attr">stored</span>=<span class="string">"true"</span> <span class="attr">multiValued</span>=<span class="string">"true"</span>/&gt;</span></div><div class="line"></div><div class="line"><span class="comment">&lt;!-- 将商品名称添加到目标域 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">copyField</span> <span class="attr">source</span>=<span class="string">"product_name"</span> <span class="attr">dest</span>=<span class="string">"product_keywords"</span> /&gt;</span></div><div class="line"><span class="comment">&lt;!-- 将商品描述添加到目标域 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">copyField</span> <span class="attr">source</span>=<span class="string">"product_description"</span> <span class="attr">dest</span>=<span class="string">"product_keywords"</span> /&gt;</span></div></pre></td></tr></table></figure></p>
<p>安装dataimportHandler插件：</p>
<ul>
<li>1 将solr-4.10.3\dist目录下拷贝solr-dataimporthandler.jar，复制到solrhome\contrib\dataimporthandler\lib下。</li>
<li>2 将mysql-connector.jar拷贝到solrhome\contrib\db\lib下。</li>
<li>3 修改solrConfig.xml，配置:</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:..&#125;/contrib/dataimporthandler/lib"</span> <span class="attr">regex</span>=<span class="string">".*\.jar"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">lib</span> <span class="attr">dir</span>=<span class="string">"$&#123;solr.install.dir:..&#125;/contrib/db/lib"</span> <span class="attr">regex</span>=<span class="string">".*\.jar"</span> /&gt;</span></div></pre></td></tr></table></figure>
<ul>
<li>4 配置solrconfig.xml，添加一个requestHandler：</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- 配置dataimport的requestHandler --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">requestHandler</span> <span class="attr">name</span>=<span class="string">"/dataimport"</span> <span class="attr">class</span>=<span class="string">"org.apache.solr.handler.dataimport.DataImportHandler"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">lst</span> <span class="attr">name</span>=<span class="string">"defaults"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">str</span> <span class="attr">name</span>=<span class="string">"config"</span>&gt;</span>data-config.xml<span class="tag">&lt;/<span class="name">str</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">lst</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">requestHandler</span>&gt;</span></div></pre></td></tr></table></figure>
<ul>
<li>5 在new_core\conf下创建data-config.xml文件：</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;  </div><div class="line"><span class="tag">&lt;<span class="name">dataConfig</span>&gt;</span>   </div><div class="line"><span class="tag">&lt;<span class="name">dataSource</span> </span></div><div class="line"><span class="tag">  <span class="attr">type</span>=<span class="string">"JdbcDataSource"</span>   </span></div><div class="line"><span class="tag">  <span class="attr">driver</span>=<span class="string">"com.mysql.jdbc.Driver"</span>   </span></div><div class="line"><span class="tag">  <span class="attr">url</span>=<span class="string">"jdbc:mysql://localhost:3306/solr"</span>   </span></div><div class="line"><span class="tag">  <span class="attr">user</span>=<span class="string">"root"</span>   </span></div><div class="line"><span class="tag">  <span class="attr">password</span>=<span class="string">"sqdyy.214"</span>/&gt;</span>   </div><div class="line">  <span class="tag">&lt;<span class="name">document</span>&gt;</span>   </div><div class="line">    <span class="tag">&lt;<span class="name">entity</span> <span class="attr">name</span>=<span class="string">"product"</span> <span class="attr">query</span>=<span class="string">"SELECT pid,name,catalog,catalog_name,price,description,picture FROM products "</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">column</span>=<span class="string">"pid"</span> <span class="attr">name</span>=<span class="string">"id"</span>/&gt;</span> </div><div class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">column</span>=<span class="string">"name"</span> <span class="attr">name</span>=<span class="string">"product_name"</span>/&gt;</span> </div><div class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">column</span>=<span class="string">"catalog"</span> <span class="attr">name</span>=<span class="string">"product_catalog"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">column</span>=<span class="string">"catalog_name"</span> <span class="attr">name</span>=<span class="string">"product_catalog_name"</span>/&gt;</span> </div><div class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">column</span>=<span class="string">"price"</span> <span class="attr">name</span>=<span class="string">"product_price"</span>/&gt;</span> </div><div class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">column</span>=<span class="string">"description"</span> <span class="attr">name</span>=<span class="string">"product_description"</span>/&gt;</span> </div><div class="line">    <span class="tag">&lt;<span class="name">field</span> <span class="attr">column</span>=<span class="string">"picture"</span> <span class="attr">name</span>=<span class="string">"product_picture"</span>/&gt;</span> </div><div class="line">    <span class="tag">&lt;/<span class="name">entity</span>&gt;</span>   </div><div class="line">  <span class="tag">&lt;/<span class="name">document</span>&gt;</span>   </div><div class="line"><span class="tag">&lt;/<span class="name">dataConfig</span>&gt;</span></div></pre></td></tr></table></figure>
<ul>
<li>6 重启tomcat，执行dataimport的execute。</li>
</ul>
<h2 id="Solrj的使用"><a href="#Solrj的使用" class="headerlink" title="Solrj的使用"></a>Solrj的使用</h2><p>solrj时访问solr服务的java客户端，提供索引和搜索的请求方法，solrj通常嵌入在业务系统中，通过solrj的api借口操作solr服务，如下图：</p>
<p>Solrj和图形界面操作的区别就类似于数据库中你使用jdbc和mysql客户端的区别一样。</p>
<h3 id="使用solrj调用solr服务实现对索引库的增删改查操作"><a href="#使用solrj调用solr服务实现对索引库的增删改查操作" class="headerlink" title="使用solrj调用solr服务实现对索引库的增删改查操作"></a>使用solrj调用solr服务实现对索引库的增删改查操作</h3><p>创建java工程，导入solrj的包(solr-6.6.0\dist\solrj-lib*)和(solr-6.6.0\dist\solr-solrj-6.6.0.jar)导入solrj的依赖包(solr-6.6.0\server\lib\ext*)。</p>
<h3 id="添加-修改索引"><a href="#添加-修改索引" class="headerlink" title="添加\修改索引"></a>添加\修改索引</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Test</span></div><div class="line"><span class="comment">// 说明：根据id（唯一约束）域来更新Document的内容，如果根据id值搜索不到id域则会执行添加操作，如果找到则更新。</span></div><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">insertAndUpdateIndex</span><span class="params">()</span> <span class="keyword">throws</span> Exception </span>&#123;</div><div class="line">    String SOLR_URL = <span class="string">"http://localhost:8081/solr/new_core"</span>;</div><div class="line">    <span class="comment">// 1 创建HttpSolrClient对象，通过它和solr服务器建立连接。</span></div><div class="line">    HttpSolrClient client = <span class="keyword">new</span> HttpSolrClient.Builder(SOLR_URL).build();</div><div class="line">    <span class="comment">// 2 创建solrInputDocument对象，通过它来添加域</span></div><div class="line">    SolrInputDocument document = <span class="keyword">new</span> SolrInputDocument();</div><div class="line">    <span class="comment">// 参数1：域名，该名称必须是在schema.xml中定义的。</span></div><div class="line">    document.addField(<span class="string">"id"</span>, <span class="string">"c0001"</span>);</div><div class="line">    document.addField(<span class="string">"name"</span>, <span class="string">"solr test111"</span>);</div><div class="line">    <span class="comment">// 3 通过HttpSolrClient对象2将solrInputDocument添加到索引库中</span></div><div class="line">    client.add(document);</div><div class="line">    <span class="comment">// 4 提交</span></div><div class="line">    client.commit();</div><div class="line">    <span class="comment">// 5 在服务端进行query查询 id:c0001</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="删除索引"><a href="#删除索引" class="headerlink" title="删除索引"></a>删除索引</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div></pre></td><td class="code"><pre><div class="line"> <span class="meta">@Test</span></div><div class="line"><span class="comment">// 根据ID删除</span></div><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">deleteDocument</span><span class="params">()</span> <span class="keyword">throws</span> Exception </span>&#123;</div><div class="line">    String SOLR_URL = <span class="string">"http://localhost:8081/solr/new_core"</span>;</div><div class="line">    <span class="comment">// 1 创建HttpSolrClient对象，通过它和solr服务器建立连接。</span></div><div class="line">    HttpSolrClient client = <span class="keyword">new</span> HttpSolrClient.Builder(SOLR_URL).build();</div><div class="line">    <span class="comment">// 2 根据ID删除</span></div><div class="line">    client.deleteById(<span class="string">"c0001"</span>);</div><div class="line">    <span class="comment">// 3 提交</span></div><div class="line">    client.commit();</div><div class="line">    <span class="comment">// 4 查询测试</span></div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="meta">@Test</span></div><div class="line"><span class="comment">// 根据条件删除</span></div><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">deleteDocumentQuery</span><span class="params">()</span> <span class="keyword">throws</span> Exception </span>&#123;</div><div class="line">    String SOLR_URL = <span class="string">"http://localhost:8081/solr/new_core"</span>;</div><div class="line">    <span class="comment">// 1 创建HttpSolrClient对象，通过它和solr服务器建立连接。</span></div><div class="line">    HttpSolrClient client = <span class="keyword">new</span> HttpSolrClient.Builder(SOLR_URL).build();</div><div class="line">    <span class="comment">// 2 根据条件删除</span></div><div class="line">    client.deleteByQuery(<span class="string">"id:c0001"</span>);</div><div class="line">    <span class="comment">// 全部删除</span></div><div class="line">    <span class="comment">//client.deleteByQuery("*:*");</span></div><div class="line">    <span class="comment">// 3 提交</span></div><div class="line">    client.commit();</div><div class="line">    <span class="comment">// 4 查询测试</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="查询索引"><a href="#查询索引" class="headerlink" title="查询索引"></a>查询索引</h3><p>先介绍solr的查询语法：</p>
<ul>
<li>1 q 查询关键字，必须的，如果查询索引使用<em>:</em></li>
<li>2 fq (filter query过滤查询)，作用：在q查询符合结果中同时时fq查询符合的(注意：请求fq是一个数组)，例如过滤查询价格从1-20的记录：product_price:[1 TO 20]，也可以用<em>表示无限，例如product_price:[20 TO </em>]</li>
<li>3 sort 排序，格式是：fieldName desc[fieldName asc]…例如按价格降序：product_price desc</li>
<li>4 start 分页显示使用，开始记录下标，从0开始</li>
<li>5 rows 指定返回结果最多有多少条记录，配合start来实现分页，实际开发时，知道当前页码和每页显示的个数最后求出开始下标。</li>
<li>6 fl 指定返回哪些字段内容，用逗号或空格分隔多个。例如只显示商品名称，价格，图片：product_name,product_price,product_picture</li>
<li>7 df 指定搜索field，例如指定我们之前定义的目标域product_keywords，也可也在new_core目录下的conf/solrconfig.xml文件中指定默认搜索field，指定后直接在”q”查询条件中输入关键字。</li>
<li>8 wt (writer type)指定输出格式，可以有xml，json，php，phps，后面solr1.3增加的，要用通知我们，因为默认没有打开。</li>
<li>9 hl是否高亮，设置高亮field，设置格式前缀和后缀，例如让name高亮：<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">hl 勾选</div><div class="line">hl.fl设置为product_name</div><div class="line">hl.simple.pre设置为<span class="tag">&lt;<span class="name">span</span> <span class="attr">color</span>=<span class="string">"red"</span>&gt;</span></div><div class="line">hl.simple.post设置为<span class="tag">&lt;/<span class="name">span</span>&gt;</span></div></pre></td></tr></table></figure>
</li>
</ul>
<p>简单查询：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Test</span></div><div class="line"><span class="comment">// 简单查询</span></div><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">search01</span><span class="params">()</span> <span class="keyword">throws</span> Exception </span>&#123;</div><div class="line">    HttpSolrClient client = <span class="keyword">new</span> HttpSolrClient.Builder(<span class="string">"http://localhost:8081/solr/new_core"</span>).build();</div><div class="line">    <span class="comment">// 创建SolrQuery对象</span></div><div class="line">    SolrQuery query = <span class="keyword">new</span> SolrQuery();</div><div class="line">    <span class="comment">// 输入查询条件</span></div><div class="line">    query.setQuery(<span class="string">"product_name:小黄人"</span>);</div><div class="line">    <span class="comment">// 执行查询并返回结果</span></div><div class="line">    QueryResponse response = client.query(query);</div><div class="line">    <span class="comment">// 获得匹配的所有记录</span></div><div class="line">    SolrDocumentList list = response.getResults();</div><div class="line">    <span class="comment">// 匹配结果总数</span></div><div class="line">    <span class="keyword">long</span> count = list.getNumFound();</div><div class="line">    System.out.println(<span class="string">"匹配结果总数："</span>+count);</div><div class="line">    <span class="keyword">for</span> (SolrDocument doc : list) &#123;</div><div class="line">        System.out.println(doc.get(<span class="string">"id"</span>));</div><div class="line">        System.out.println(doc.get(<span class="string">"product_name"</span>));</div><div class="line">        System.out.println(doc.get(<span class="string">"product_catalog"</span>));</div><div class="line">        System.out.println(doc.get(<span class="string">"product_price"</span>));</div><div class="line">        System.out.println(doc.get(<span class="string">"product_picture"</span>));</div><div class="line">        System.out.println(<span class="string">"======================="</span>);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>复杂查询：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Test</span></div><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">search02</span><span class="params">()</span> <span class="keyword">throws</span> Exception </span>&#123;</div><div class="line">    HttpSolrClient client = <span class="keyword">new</span> HttpSolrClient.Builder(<span class="string">"http://localhost:8081/solr/new_core"</span>).build();</div><div class="line">    <span class="comment">// 创建SolrQuery对象</span></div><div class="line">    SolrQuery query = <span class="keyword">new</span> SolrQuery();</div><div class="line">    </div><div class="line">    <span class="comment">// 输入查询条件</span></div><div class="line">    query.setQuery(<span class="string">"product_name:小黄人"</span>);</div><div class="line">    <span class="comment">//query.set("q", "product_name:小黄人");</span></div><div class="line">    </div><div class="line">    <span class="comment">// 设置过滤条件</span></div><div class="line">    <span class="comment">// 如果设置多个过滤条件的话，需要使用query.addFilterQuery(fq)</span></div><div class="line">    query.setFilterQueries(<span class="string">"product_price:[1 TO 10]"</span>);</div><div class="line">    </div><div class="line">    <span class="comment">// 设置排序</span></div><div class="line">    query.setSort(<span class="string">"product_price"</span>, ORDER.desc);</div><div class="line">    </div><div class="line">    <span class="comment">// 设置分页信息</span></div><div class="line">    query.setStart(<span class="number">0</span>);</div><div class="line">    query.setRows(<span class="number">10</span>);</div><div class="line">    </div><div class="line">    <span class="comment">// 设置显示的Field的域几个</span></div><div class="line">    query.setFields(<span class="string">"id,product_name,product_catalog,product_price,product_picture"</span>);</div><div class="line">    </div><div class="line">    <span class="comment">// 设置默认域</span></div><div class="line">    query.set(<span class="string">"df"</span>, <span class="string">"product_keywords"</span>);</div><div class="line">    </div><div class="line">    <span class="comment">// 设置高亮信息</span></div><div class="line">    query.setHighlight(<span class="keyword">true</span>);</div><div class="line">    query.addHighlightField(<span class="string">"product_name"</span>);</div><div class="line">    query.setHighlightSimplePre(<span class="string">"&lt;span color=\"red\"&gt;"</span>);</div><div class="line">    query.setHighlightSimplePre(<span class="string">"&lt;/span&gt;"</span>);</div><div class="line">    </div><div class="line">    <span class="comment">// 执行查询并返回结果</span></div><div class="line">    QueryResponse response = client.query(query);</div><div class="line">    SolrDocumentList list = response.getResults();</div><div class="line">    <span class="keyword">long</span> count = list.getNumFound();</div><div class="line">    System.out.println(<span class="string">"匹配结果总数:"</span> + count);</div><div class="line">    </div><div class="line">    <span class="comment">// 获得高亮显示信息</span></div><div class="line">    Map&lt;String, Map&lt;String, List&lt;String&gt;&gt;&gt; highlighting = response.getHighlighting();</div><div class="line">    <span class="keyword">for</span> (SolrDocument doc : list) &#123;</div><div class="line">        System.out.println(doc.get(<span class="string">"id"</span>));</div><div class="line">        </div><div class="line">        List&lt;String&gt; list2 = highlighting.get(doc.get(<span class="string">"id"</span>)).get(<span class="string">"product_name"</span>);</div><div class="line">        <span class="keyword">if</span>(list2 != <span class="keyword">null</span>)</div><div class="line">            System.out.println(<span class="string">"高亮显示的商品名称："</span> + list2.get(<span class="number">0</span>));</div><div class="line">        <span class="keyword">else</span> &#123;</div><div class="line">            System.out.println(doc.get(<span class="string">"product_name"</span>));</div><div class="line">        &#125;</div><div class="line">        </div><div class="line">        System.out.println(doc.get(<span class="string">"product_catalog"</span>));</div><div class="line">        System.out.println(doc.get(<span class="string">"product_price"</span>));</div><div class="line">        System.out.println(doc.get(<span class="string">"product_picture"</span>));</div><div class="line">        System.out.println(<span class="string">"====================="</span>);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-12-05T09:59:55.098Z" itemprop="dateUpdated">2017年12月5日 17:59</time>
</span><br>


        如要转载请注明出处：<a href="/2017/09/04/Solr6.6.0_primary_01/" target="_blank" rel="external">http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/</a>
    </div>
    <footer>
        <a href="http://magic_duck.oschina.io">
            <img src="/img/avatar.jpg" alt="神奇的鸭鸭">
            神奇的鸭鸭
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/全文检索/">全文检索</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/&title=《全文检索技术Solr6.6.0》 — 神奇的鸭鸭の码农库&pic=http://magic_duck.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/&title=《全文检索技术Solr6.6.0》 — 神奇的鸭鸭の码农库&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《全文检索技术Solr6.6.0》 — 神奇的鸭鸭の码农库&url=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/&via=http://magic_duck.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/09/06/redis4.4.0_primary_01/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Redis基础入门</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/09/04/solr6.6.0_exception_01/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">solr6.6.0异常</h4>
      </a>
    </div>
  
</nav>



    







</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        我只要一角钱~ ~
        <i class="icon icon-quote-right"></i>
    </h3>
    <ul class="reward-items">
        
        <li>
            <img src="/img/wechat.png" title="微信打赏二维码" alt="微信打赏二维码">
            <p>微信</p>
        </li>
        

        
        <li>
            <img src="/img/alipay.jpg" title="支付宝打赏二维码" alt="支付宝打赏二维码">
            <p>支付宝</p>
        </li>
        
    </ul>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            <span><a href="" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            <span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://git.oschina.net/z77z" target="_blank">邹海清</a></span>
            <span>神奇的鸭鸭の码农库 &copy; 2017</span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/&title=《全文检索技术Solr6.6.0》 — 神奇的鸭鸭の码农库&pic=http://magic_duck.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/&title=《全文检索技术Solr6.6.0》 — 神奇的鸭鸭の码农库&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《全文检索技术Solr6.6.0》 — 神奇的鸭鸭の码农库&url=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/&via=http://magic_duck.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=http://magic_duck.oschina.io/2017/09/04/Solr6.6.0_primary_01/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };



lazyScripts.push('//s95.cnzz.com/z_stat.php?id=1261081671&web_id=1261081671')

</script>

<script src="/js/main.min.js?v=1.4.3"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="/js/search.min.js?v=1.4.3" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>


</body>
</html>
